<?php
/**
count by where clause
<!--[count_from_db table="innoforum_topics" group_by="tpc_type_id" where="tpc_type_id = '3'"]-->
*/
function smarty_function_count_top_post ($params, &$smarty) 
{
    $sql = "SELECT
              member_point.userid,
              zk_users.pn_uname,
              zk_user_data.pn_uda_value,
              SUM(member_point.subcount) AS totalcount
            FROM
              (
                  SELECT
                    zk_dizkus_posts.poster_id AS userid,
                    COUNT(zk_dizkus_posts.post_id) AS subcount
                  FROM
                    zk_dizkus_posts
                  WHERE
                    MONTH(zk_dizkus_posts.post_time) = MONTH(NOW()) AND YEAR(zk_dizkus_posts.post_time) = YEAR(NOW())
                  GROUP BY
                    zk_dizkus_posts.poster_id
              )
              AS member_point,
              zk_users,
              zk_user_data
              WHERE 
               member_point.userid IS NOT NULL
              AND
               member_point.userid != 2
              AND 
               member_point.userid != 58
              AND 
               member_point.userid != 1841
              AND 
               member_point.userid = pn_uid
              AND
               member_point.userid = pn_uda_uid
              AND
               pn_uid = pn_uda_uid
              AND
               pn_uda_propid = 1              
              GROUP BY member_point.userid
              ORDER BY totalcount DESC
              LIMIT 0,10";

    $column = array("userid","pn_uname","pn_uda_value","totalcount");
    $result = DBUtil::executeSQL($sql);
    $objectArray = DBUtil::marshallObjects ($result, $column);

    $smarty->assign('topuser', $objectArray);

}
?>